<html>
<head><meta charset="utf-8"><title>renaming TyCtxt · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html">renaming TyCtxt</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="151111055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111055">(Dec 07 2018 at 13:28)</a>:</h4>
<p>I think we should add two aliases for TyCtxt and start using them:</p>
<div class="codehilite"><pre><span></span>type Qx&lt;&#39;qx&gt; = TyCtxt&lt;&#39;static, &#39;qx, &#39;qx&gt;;
type Lx&lt;&#39;qx, &#39;lx&gt; = TyCtxt&lt;&#39;static, &#39;qx, &#39;lx&gt;;
</pre></div>


<p>In the future we might want to make these separate type so we could drop the local <code>interner</code> field from <code>Qx</code>.</p>



<a name="151111372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111372">(Dec 07 2018 at 13:32)</a>:</h4>
<p>I'm not sure that's the best distinction</p>



<a name="151111391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111391">(Dec 07 2018 at 13:32)</a>:</h4>
<p>also, the lifetime order is wrong (as it has been pointed out for a while)</p>



<a name="151111447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111447">(Dec 07 2018 at 13:33)</a>:</h4>
<p>and I'd make <code>'a</code> equal to (the current) <code>'tcx</code> not <code>'static</code>, just to keep a few things simpler</p>



<a name="151111465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111465">(Dec 07 2018 at 13:33)</a>:</h4>
<p>also, there's a real question of whether we need the local split at all anymore</p>



<a name="151111543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111543">(Dec 07 2018 at 13:34)</a>:</h4>
<p>4 years ago or so, when I gathered the stats that led to the split, for <code>librustc</code> I found something like 90% of the interner entries had inference variables in them</p>



<a name="151111557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151111557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151111557">(Dec 07 2018 at 13:35)</a>:</h4>
<p>I wonder if Chalk and everything else change the calculus here</p>



<a name="151112606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151112606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151112606">(Dec 07 2018 at 13:51)</a>:</h4>
<p>also, the naming scheme I used in <code>rustc_codegen_llvm</code> would mean <code>qx: QueryCx</code>, not <code>qx: Qx</code></p>



<a name="151112672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151112672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151112672">(Dec 07 2018 at 13:52)</a>:</h4>
<p>that is, the type is written less often and should be more descriptive than the variable names</p>



<a name="151112683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151112683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151112683">(Dec 07 2018 at 13:52)</a>:</h4>
<p><code>Cx</code> is enough to indicate "context"</p>



<a name="151112699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151112699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151112699">(Dec 07 2018 at 13:53)</a>:</h4>
<p><code>lx: LocalCx</code> doesn't seem so bad, and we can relatively easily rename it if we find something better</p>



<a name="151113244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151113244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151113244">(Dec 07 2018 at 14:01)</a>:</h4>
<p>although it still looks... off to me</p>



<a name="151113277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151113277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151113277">(Dec 07 2018 at 14:01)</a>:</h4>
<p><code>tx: TyCx</code> might be better</p>



<a name="151113345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151113345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151113345">(Dec 07 2018 at 14:02)</a>:</h4>
<p>not to mention you don't want to take a <code>QueryCx</code> if you want to perform a query, as we have no way to automate what we currently call <code>.global_tcx()</code></p>



<a name="151113513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151113513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151113513">(Dec 07 2018 at 14:04)</a>:</h4>
<p>maybe if we make them references we can do some trickery - I remember not being able to pull off something sensible but maybe that's because I wanted access to the fields on <code>GlobalCtxt</code> - if we move <code>hir</code> to a method that might not be a problem anymore?</p>



<a name="151113553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151113553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151113553">(Dec 07 2018 at 14:05)</a>:</h4>
<p>I guess you'd still not want to have a cyclic <code>Deref</code> impl and it wouldn't even work meh</p>



<a name="151114282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151114282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151114282">(Dec 07 2018 at 14:16)</a>:</h4>
<p>What do you mean you don't want a <code>QueryCx</code> if you want to perform a query?</p>



<a name="151123016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151123016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151123016">(Dec 07 2018 at 16:23)</a>:</h4>
<p>because it's too restrictive</p>



<a name="151123023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151123023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151123023">(Dec 07 2018 at 16:23)</a>:</h4>
<p>I can't just pass a local context to it</p>



<a name="151123112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151123112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151123112">(Dec 07 2018 at 16:24)</a>:</h4>
<p>in today's terms, <code>TyCtxt&lt;'_, 'tcx, 'tcx&gt;</code> is unnecessarily restrictive as a function argument type</p>



<a name="151532901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151532901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151532901">(Dec 12 2018 at 15:37)</a>:</h4>
<p>btw, in Salsa we adopted the term "database" instead of "context", with the acronym <code>db</code>... I sort of like it better</p>



<a name="151532967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151532967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151532967">(Dec 12 2018 at 15:38)</a>:</h4>
<p>re: whether the global/local split is worthwhile, I've been wondering that. I think that for Chalk integration -- which requires ultimately "inference variables" that persist beyond an individual function etc -- I'd ultimately rather not use <code>TyVar</code> but just keep everything in the global arena, but it's not entirely clear yet</p>



<a name="151532979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151532979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151532979">(Dec 12 2018 at 15:38)</a>:</h4>
<p>In any case I think we should think carefully about the names -- this is a chance to make the compiler more accessible</p>



<a name="151619822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/renaming%20TyCtxt/near/151619822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/renaming.20TyCtxt.html#151619822">(Dec 13 2018 at 16:28)</a>:</h4>
<p>BTW, in some places we use db for diagnostic builder, instead of err.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>